var ejs = require("ejs");
var fs = require("fs");
var http = require("http");

var server = http.createServer(function(req,res){
    fs.readFile("./views/index.ejs",function(err,data){
        var template = data.toString(); // 绑定模板
        var dictionary = {
            a:8,
            news : [
                {"title":"陈伟霆最帅","count":10},
                {"title":"胡一天最帅","count":20},
                {"title":"我是最帅的","count":30},
            ]
        };
        var html = ejs.render(template,dictionary); // 

        res.writeHead(200,{"Content-Type":"text/html;charset=UTF8"});        
        res.end(html);
    })
});
server.listen(3000,"127.0.0.1");